package Negocio;

import java.util.ArrayList;
import java.util.List;

import DTO.DTO_PlanProdSemiElab;
import DTO.DTO_Tarea;
import Entities.Entity_PlanProdSemiElab;
import Entities.Entity_Tarea;

public class PlanProdSemiElab {
	
	private List<Tarea> tareas;
	private int horasDisponible;
	
	//Constructores
	public PlanProdSemiElab(List<Tarea> tareas, int horasDisponible) {
		super();
		this.tareas = tareas;
		this.horasDisponible = horasDisponible;
	}
	
	public PlanProdSemiElab(DTO_PlanProdSemiElab p){
		this.tareas = new ArrayList<Tarea>();
		for(DTO_Tarea t : p.getTareas()){
			this.tareas.add(new Tarea(t));
		}
		this.horasDisponible = p.getHorasDisponible();
	}
	
	
	public PlanProdSemiElab(Entity_PlanProdSemiElab p){
		this.tareas = new ArrayList<Tarea>();
		for(Entity_Tarea t : p.getTareas()){
			this.tareas.add(new Tarea(t));
		}
		this.horasDisponible = p.getHorasDisponible();
	}
	
	public PlanProdSemiElab() {
	}

	//GET & SET
	public List<Tarea> getTareas() {
		return tareas;
	}

	public void setTareas(List<Tarea> tareas) {
		this.tareas.addAll(tareas);
	}

	public int getHorasDisponible() {
		return horasDisponible;
	}

	public void setHorasDisponible(int horasDisponible) {
		this.horasDisponible = horasDisponible;
	}
	
	public DTO_PlanProdSemiElab toDTO(){
		DTO_PlanProdSemiElab dto_PlanProdSemiElab = new DTO_PlanProdSemiElab();
		dto_PlanProdSemiElab.setHorasDisponible(this.horasDisponible);
		List<DTO_Tarea> dto_Tareas = new ArrayList<DTO_Tarea>();
		for(Tarea t : this.tareas)
			dto_Tareas.add(t.toDTO());
		dto_PlanProdSemiElab.setTareas(dto_Tareas);
		return dto_PlanProdSemiElab;
	}
	
	public Entity_PlanProdSemiElab toEntity(){
		Entity_PlanProdSemiElab dto_PlanProdSemiElab = new Entity_PlanProdSemiElab();
		dto_PlanProdSemiElab.setHorasDisponible(this.horasDisponible);
		List<Entity_Tarea> dto_Tareas = new ArrayList<Entity_Tarea>();
		for(Tarea t : this.tareas)
			dto_Tareas.add(t.toEntity());
		dto_PlanProdSemiElab.setTareas(dto_Tareas);
		return dto_PlanProdSemiElab;
	}

	

}
